package com.yifeng.service.impl;

import com.yifeng.dao.MenuMapper;
import com.yifeng.po.Menu;
import com.yifeng.service.IMenuService;
import com.yifeng.util.BlogResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Iterator;
import java.util.List;

@Service
public class MenuServiceServiceImpl extends BaseServiceImpl<Menu> implements IMenuService {

    @Autowired
    private MenuMapper menuMapper;

    public BlogResult<Menu> findUserMenuByLoginUserId(Long loginUserId) {
        List<Menu> menus = menuMapper.loadUserMenuByLoginUserId(loginUserId);

        for(int i= 0 ; i<menus.size();i++){
            if(menus.get(i).getId() == null){
                System.out.println("有空数据！");
                Menu m = menus.get(i).getChildren().get(0);
                menus.remove(i);
                menus.add(m);
            }
        }

        return new BlogResult(200,"ok",  menus);
    }

}
